import * as React from 'react';
import RouterComponent from "./routers";
import ModalArray from "./models/index";
import Request from "./utils/Request";
import api from "./utils/Api";
import RouterServer from "./utils/RouterServer";
const { Actions } = require('react-native-router-flux');
const { create } = require('dva-core');
const { autoRehydrate } = require('redux-persist');
const { Provider } = require('react-redux');
const { debug } = require('../app.json');
Request.init(api, debug, 30 * 1000, {
    'invalid_token': (error) => {
        if (Actions.currentScene !== 'auth') {
            RouterServer.replace('auth');
        }
    },
    'Unauthorized': (error) => {
        if (Actions.currentScene !== 'auth') {
            RouterServer.replace('auth');
        }
    }
});
const app = create({
    extraEnhancers: [autoRehydrate()],
    onError: (e) => {
    },
});
const initModels = (models = []) => {
    models.map((mode) => {
        app.model(mode);
    });
};
initModels(ModalArray);
app.start();
export default class App extends React.Component {
    constructor(props, context) {
        super(props, context);
    }
    shouldComponentUpdate(nextProps, nextState, nextContext) {
        console.log('app can update', this.props, nextProps);
        return null;
    }
    render() {
        return (<Provider store={app._store}>
                <RouterComponent />
            </Provider>);
    }
}
